package com.sunmouse.toollib.utils.region;

import android.app.Activity;


import java.io.InputStream;
import java.util.ArrayList;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

/**
 * Created by Kvin on 2017/5/26.
 */
public class RegionUtils {

    public static final String PROVINCE_DATA="file:///province_data.xml";

    public static ArrayList<ProvinceBean> loadingProvince(Activity act) {
        try {
            InputStream is=act.getAssets().open("province_data.xml");
            SAXParserFactory mFactory = SAXParserFactory.newInstance();
            SAXParser mParser = mFactory.newSAXParser();
            XmlParserHandler mXmlParserHandler=new XmlParserHandler();
            mParser.parse(is,mXmlParserHandler);
            is.close();
            return mXmlParserHandler.getProvinceList();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
